<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>调出设备类</title>
	<link rel="stylesheet" type="text/css" href="../../../resource/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="../../../resource/css/user_css/publicStyle.css">
	<link rel="stylesheet" type="text/css" href="../../../resource/layui/css/layui.css"/>
	<link rel="stylesheet" type="text/css" href="../../../resource/css/niubility.css"/>
	<!-- 购入、调入,调出，维修维护，报损报废相同的css样式 -->
	<link rel="stylesheet" type="text/css" href="../../../resource/css/user_css/purchase_diaoRu_style.css"/>
	<script type="text/javascript" src="../../../resource/layui/layui.js"></script>
</head>
<body>
	<form action="" method="post" id="formAddDevice">
		<div class="boxOne">
			<div class="form-group">
		      	<label>请选择设备类别:</label>
			    <select  class="form-control" name="equipmentCategory" id="category">
				  <option value="-1">--未选择--</option>
				</select>
			</div>
			<div class="form-group" >
				<label>请选择设备名称:</label>
				<select  class="form-control" name="equipmentName" id="name">
					<option value="-1">--未选择--</option>
				</select>
			</div>
			<div class="form-group" >
				<label>请选择设备编号:</label>
				<select  class="form-control" name="equipmentNo" id="number">
					<option value="-1">--未选择--</option>
				</select>
			</div>
			<div class="form-group" >
				<label >调拨原因:</label>
				<textarea id="transerReason" name="transerReason" class="form-control" style="width: 300px;height: 90px;"></textarea>
			</div>
		</div>	
		<div class="boxOne">
			<div class="form-group" >
				<label for="diaoDate">调拨日期:</label>
				<input type="date"  class="form-control" name="transerDate" id="diaoDate" >
			</div>
			<div class="form-group">
	      	  <label >调出单位:</label>
	          <input type="text" class="form-control" name="transerOutUnit" value="计算机科学学院" id="diaoOutUnit" >
	    	</div>
	    	<div class="form-group">
	      	  <label for="diaoRuUnit">调入单位:</label>
	          <input type="text" class="form-control" name="transerInUnit" id="diaoRuUnit" >
	    	</div>
		</div>

		<div style="clear: both;"></div>
	    <button type="button" class="btn btn-default" id="btn">提交</button>
	</form>
	<script type="text/javascript" src="../../../resource/js/jquery.min.js"></script>
	<!-- 静态url路径 -->
	<script type="text/javascript" src="../../../resource/js/static_url.js"></script>
	<!-- 表单序列化提交：购入、调入、调出、维修维护、报损报废、装让 -->
	<script type="text/javascript" src="../../../resource/js/user_js/user_post_serialize.js"></script>
	<!--设备类别 + 设备名称 + 设备编号-->
	<script type="text/javascript" src="../../../resource/js/user_js/equipmentTableThree.js"></script>
	<!--表单验证-->
	<script type="text/javascript">
/*--------------------------必填的验证---------------------------------*/
		// ----------设备的三级联动
		$("#btn").click(function(){
		    /* 检验设备类别 , 设备名称 ， 设备编号
		    （1）不能位 -1 ，
		    */
			var category = $("#category").val();
			var name = $("#name").val();
			var number = $("#number").val();
			if(category==-1){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，要正确选择设备类别', '#category', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
			   return;
			}
            if(name==-1){

                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，要正确选择设备名称', '#name', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
            }
            if(number==-1){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，要正确选择设备编号', '#number', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
            }

            /*
            * 调拨日期：
            * （1）不能为空
            * （2）不能选择大于当前时间内容
            * */
            var transerDate = $("#diaoDate").val();
            if(transerDate == ''){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，填写您忘记填写调拨日期了', '#diaoDate', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
			}
            var db = new Date(transerDate.replace(/-/g, "/"));
            var d = new Date();
            var str = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
            if(Date.parse(str)<Date.parse(db)){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，调拨时间不能大于当前时间', '#diaoDate', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return ;
			}

            /*调入单位：
            （1）不能为空
            （2）长度<25
            * */
            var diaoRuUnit = $("#diaoRuUnit").val();
            if(diaoRuUnit==''){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，调拨单位不能为空', '#diaoRuUnit', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
			}
            if(diaoRuUnit.length>25){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，调拨的单位的名字不能超过25个字符', '#diaoRuUnit', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
			}
            /*--------------------------选填项验证： 调拨原因------------------------------*/
            /*
           * 调拨原因
           * （1）可以为空 ，长度不能超过150个字符
           * */
            var transerReason = $("#transerReason").val;
            if(transerReason.length>150){
                layui.use('layer', function(){
                    var layer = layui.layer;
                    layer.tips('亲，调拨原因最多不能超过150个字符', '#transerReason', {
                        tips: [1, '#333'],
                        time: 2500,
                    });
                });
                return;
            }

            //--- 提交数据
            post_serialize(user_diaochu_post);
		});

		// 设置默认时间
		var myDate = new Date();
		var year = myDate.getFullYear();
		var month = myDate.getMonth()+1;
		var day = myDate.getDate();
		//判断 月份、天数 <10的时候前面加 0
		if(month < 10){
			month = "0"+month;
		}
		if(day < 10){
			day = "0"+day;
		}
		var time = year +"-"+ month +"-"+ day;
		$("#diaoDate").val(time);
	</script>
</body>
</html>